<?
include("class.phpmailer.php");
include("class.smtp.php");
	
function send_email($to_email,$to_name, $subject,$message,$arrBcc=array(),$html=true,$from_email="",$from_name="")
{
global $email_admin,$email_name,$send_smtp,$smtp_host,$smtp_user,$smtp_pass,$smtp_auth,$smtp_port,$smtp_ssl,$email_forward;

	if($to_email=="")
	{
		echo "Empty to email!";
		return false;
	}
	if($from_email=="")$from_email=$email_admin;
	if($from_name=="")$from_name=$email_name;

	$mail = new PHPMailer();
	
	if($send_smtp==true)$mail->IsSMTP(); // send via SMTP
	if($smtp_ssl===true)$mail->SMTPSecure = "ssl";		
	if($smtp_auth===true)$mail->SMTPAuth =true; // turn on SMTP authentication
	
	//$mail->SMTPDebug  = 2; 
	
	$mail->Host = $smtp_host; // SMTP servers
	$mail->Port= ($smtp_port>0)? $smtp_port : 25;	
	
	$mail->Username = $smtp_user; // SMTP username
	$mail->Password = $smtp_pass; // SMTP password
	
	$mail->SetFrom($from_email, $from_name);
	$mail->AddReplyTo($from_email,$from_name);
	
	$mail->AddAddress($to_email,$to_name); 
	
	//add bcc if has:
	if(is_array($arrBcc)==false)$arrBcc=array();
	foreach($arrBcc as $i => $email)
	{
		$mail->AddBCC($email,""); 
	}
	
	$mail->WordWrap = 50; // set word wrap
	$mail->IsHTML($html); // send as HTML
	$mail->CharSet = "UTF-8";
	
	$mail->Subject = $subject;
	$mail->Body = $message.$email_forward;
	$mail->AltBody = "";
	if(!$mail->Send())
	{		
		return false;	
	}
	return true;
} 
?>